#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll N=1e8+1;
ll v[N];
ll n,m,ind;
bool visited[N];
int main(void)
{
	std::ios::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
	cin>>n>>m;
	for(int i=2;i*i<N;i++)
	{
		if(visited[i]==false)
		{
			for(int j=i*i;j<N;j+=i)
			{
				visited[j]=true;
			}
		}
	}
	for(int i=2;i<N;i++)
	{
		if(visited[i]==false)
			v[++ind]=i;
	}
	while(m--)
	{
		ll t;
		cin>>t;
		cout<<v[t]<<endl;
	}
}
